package com.example.demo.mapper;


import com.example.demo.entity.Tag;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TagMapper {
    // 查询标签 ID
    @Select("SELECT id FROM tag WHERE name = #{name}")
    Long selectTagIdByName(@Param("name") String name);

    // 插入标签
    @Insert("INSERT INTO tag (name) VALUES (#{name})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertTag(Tag tag);
    //查询所有标签
    @Select("SELECT * FROM tag")
    List<Tag> selectAllTag();
}
